package com.nullpointer.xchat.object;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import flexjson.JSONDeserializer;
import flexjson.JSONSerializer;

public class UserInfo {
	private GenderType gender = GenderType.FEMALE;
	private String status;

	public enum GenderType {
		FEMALE, MALE, ANY
	}

	public static String[] genderText = { "female", "male", "other" };

	public GenderType getGender() {
		return gender;
	}

	public void setGender(GenderType gender) {
		this.gender = gender;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String toJson() {
		return new JSONSerializer().exclude("*.class").deepSerialize(this);
	}

	public static UserInfo fromJsonToUserInfo(String json) {
		return new JSONDeserializer<UserInfo>().use(null, UserInfo.class)
				.deserialize(json);
	}

	public static String toJsonArray(Collection<UserInfo> collection) {
		return new JSONSerializer().exclude("*.class")
				.deepSerialize(collection);
	}

	public static Collection<UserInfo> fromJsonArrayToUserInfos(String json) {
		return new JSONDeserializer<List<UserInfo>>()
				.use(null, ArrayList.class).use("values", UserInfo.class)
				.deserialize(json);
	}

}
